package com.juyu.miliao.api.service.whitepacket;

import com.juyu.miliao.api.dao.mysql.WhitePacketCommentReplyInfoDao;
import com.juyu.miliao.api.dao.mysql.WhitePacketDynamicCommentInfoDao;
import com.juyu.miliao.api.dao.redis.DynamicCommentInfoRedisDao;
import com.juyu.miliao.api.domain.CommentReplyInfo;
import com.juyu.miliao.api.domain.DynamicCommentInfo;
import com.juyu.miliao.api.domain.WhitePacketCommentReplyInfo;
import com.juyu.miliao.api.domain.WhitePacketDynamicCommentInfo;
import com.juyu.miliao.api.domain.dto.CommentReplyInfoDTO;
import com.juyu.miliao.api.domain.dto.WhitePacketCommentReplyInfoDTO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author xuanqicheng
 * @create 2019-21-15:35
 */
@Service
public class WhitePacketCommentReplyInfoService {
    @Autowired
    private WhitePacketCommentReplyInfoDao whitePacketCommentReplyInfoDao;

    @Autowired
    private WhitePacketDynamicCommentInfoDao whitePacketDynamicCommentInfoDao;
    /**
     * 添加回复信息
     * @param commentReplyInfoDTO
     */
    public void addCommentReply(WhitePacketCommentReplyInfoDTO commentReplyInfoDTO) {


        long commentId = commentReplyInfoDTO.getCommentId();
        WhitePacketDynamicCommentInfo obj =whitePacketDynamicCommentInfoDao.getDynamciCommentById(commentId);

        WhitePacketCommentReplyInfo commentReplyInfo = new WhitePacketCommentReplyInfo();

        BeanUtils.copyProperties(commentReplyInfoDTO,commentReplyInfo);

        commentReplyInfo.setReplyToUserId(obj.getFromUserId());

        whitePacketCommentReplyInfoDao.addCommentReply(commentReplyInfo);

    }
}
